package com.yidu.BusinessData.service.impl;

import com.yidu.BusinessData.entity.SecurityEntity;
import com.yidu.BusinessData.mapper.SecurityMapper;
import com.yidu.BusinessData.service.SecurityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**@description: 证券信息Impl
 *@author: 肖理
 *@create: 2022-09-10
 **/
@Service
public class SecurityImpl implements SecurityService {
    @Autowired
    SecurityMapper securityMapper;
    @Override
    public int securityInsert(SecurityEntity securityEntity) {
        return securityMapper.securityInsert(securityEntity);
    }

    @Override
    public List<SecurityEntity> securitySelect(String securityName,int page,int limit) {
        Map map=new HashMap();
        map.put("securityName",securityName);
        map.put("page",(page-1)*limit);
        map.put("limit",limit);
        return securityMapper.securitySelect(map);
    }

    @Override
    public int securitySelecttwo(String securityName) {
        return securityMapper.securitySelecttwo(securityName);
    }

    @Override
    public int securityDelete(String securityId) {
        //切割字符串
        String[] split = securityId.split(",");
        ArrayList<Object> list=new ArrayList<>();
        int i = 0;
        for (String id : split) {
            list.add(id);
            i = securityMapper.securityDelete(id);
        }
        System.out.println(list);
        return i;
    }

    @Override
    public int securityUpdate(SecurityEntity securityEntity) {
        return securityMapper.securityUpdate(securityEntity);
    }
}
